/**
 * Copyright (c) 2002-2011 旭鸣信息
 * All rights reserved. 
 * File：GoodsTypeContorller.java
 * History:
 *       May 13, 2012: Initially created, liuzhi.
 */
package com.xteam.ecsystem.contorller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tangkf.utils.bean.ReqHelper;
import com.xteam.ecsystem.service.admin.SystemLogService;
import com.xteam.ecsystem.utils.ConstantLocation;

/**
 * 系统日志控制枢纽站
 * @author liuzhi
 *
 */
@Controller
public class SystemLogContorller {

	@Autowired
	private SystemLogService logService;
	
	@RequestMapping("/getSystemLogList.do")
	public void getSystemLogList(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws IOException {
		int pageIndex = ReqHelper.getRequestInt(request, "pageIndex");
		int pageSize = ReqHelper.getRequestInt(request, "pageSize");
		String lslUser = ReqHelper.getRequestString(request, "lslUser");
		String lslAddress = ReqHelper.getRequestString(request, "lslAddress");
		String startTime = ReqHelper.getRequestString(request, "startTime");
		String endTime = ReqHelper.getRequestString(request, "endTime");
		
		String strList = logService.getSystemLogList(pageIndex, pageSize, lslUser, 
				lslAddress, startTime, endTime);
		response.getWriter().write(strList);
	}
	
	@RequestMapping("/delSystemLogByIds.do")
	public void delSystemLogByIds(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws IOException {
		String lslIds = ReqHelper.getRequestString(request, "lslIds");
		String lslUser = ReqHelper.getRequestString(request, "lslUser");
		String lslAddress = ReqHelper.getRequestString(request, "lslAddress");

		this.logService.delSystemLogsByIds(lslIds);
		
		this.logService.saveSystemLogs(lslUser, lslAddress, ConstantLocation.LOG_SYSTEMLOG_MGR, 
				"delSystemLogsByIds", ConstantLocation.LOG_BATCH_DELETE, "LogSystemLog");
	}
	
	@RequestMapping("/delSystemLogByCon.do")
	public void delSystemLogByCon(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws IOException {
		String condition = ReqHelper.getRequestString(request, "condition");
		String lslUser = ReqHelper.getRequestString(request, "lslUser");
		String lslAddress = ReqHelper.getRequestString(request, "lslAddress");

		this.logService.delSystemLogByCon(condition);
		
		this.logService.saveSystemLogs(lslUser, lslAddress, ConstantLocation.LOG_SYSTEMLOG_MGR, 
				"delSystemLogByCon", ConstantLocation.LOG_BATCH_DELETE, "LogSystemLog");
	}
	
	
}
